using System;
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Ccr.Core;
using Microsoft.Dss.Core.DsspHttp;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using Microsoft.Dss.ServiceModel.DsspServiceBase;
using W3C.Soap;

namespace SimJaguarsControl
{
    /// <summary>
    /// SimJaguarsControl contract class
    /// </summary>
    public sealed class Contract
    {
        /// <summary>
        /// DSS contract identifer for SimJaguarsControl
        /// </summary>
        [DataMember]
        public const string Identifier = "http://erobots.jcepeda.simjaguarscontrol/2011/09/simjaguarscontrol.html";
    }

    /// <summary>
    /// SimJaguarsControl main operations port
    /// </summary>
    [ServicePort]
    public class SimJaguarsControlOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, Replace,
        Update, WatchDogUpdate, HttpGet, Subscribe>
    {
    }

    /// <summary>
    /// SimJaguarsControl get operation
    /// </summary>
    public class Get : Get<GetRequestType, PortSet<SimJaguarsControlState, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        public Get()
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        public Get(GetRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Get
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Get(GetRequestType body, PortSet<SimJaguarsControlState, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    /// <summary>
    /// SimJaguarsControl subscribe operation
    /// </summary>
    public class Subscribe : Subscribe<SubscribeRequestType, PortSet<SubscribeResponseType, Fault>>
    {
        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        public Subscribe()
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        public Subscribe(SubscribeRequestType body)
            : base(body)
        {
        }

        /// <summary>
        /// Creates a new instance of Subscribe
        /// </summary>
        /// <param name="body">the request message body</param>
        /// <param name="responsePort">the response port for the request</param>
        public Subscribe(SubscribeRequestType body, PortSet<SubscribeResponseType, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    public class Replace : Replace<SimJaguarsControlState, PortSet<DefaultReplaceResponseType, Fault>>
    {
        public Replace(SimJaguarsControlState body)
            : base(body)
        { }

        public Replace()
        { }
    }

    public class Update : Update<SimJaguarsControlState, PortSet<DefaultReplaceResponseType, Fault>>
    {
    }

    /// <summary>
    /// Imported from the Pioneer Control Robot.
    /// </summary>
    [Description("Provides an update to the watchdog state.")]
    public class WatchDogUpdate : Update<WatchDogUpdateRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public WatchDogUpdate(WatchDogUpdateRequest body)
            : base(body)
        { }

        public WatchDogUpdate()
        { }
    }
    [DataContract]
    public class WatchDogUpdateRequest
    {
        private DateTime _timeStamp;

        [DataMember]
        [Description("Indicates the time of the reading (in ms).")]
        public DateTime TimeStamp
        {
            get { return _timeStamp; }
            set { _timeStamp = value; }
        }

        public WatchDogUpdateRequest(DateTime timeStamp)
        {
            TimeStamp = timeStamp;
        }

        public WatchDogUpdateRequest()
        { }
    }


    #region WinForms communication

    public class FromWinformEvents : Port<FromWinformMsg>
    {
    }

    public class FromWinformMsg
    {
        public enum MsgEnum
        {
            Loaded,
            Drag,
            Zoom,
            Close,
            ConsoleTest  //-->This MsgEnum is for testing the messaging from MainForm to SimJaguarsControl.cs
                         //   there is a switch case in OnWinformMessageHandler for console printing.
        }

        private string[] _parameters;
        public string[] Parameters
        {
            get { return _parameters; }
            set { _parameters = value; }
        }

        private MsgEnum _command;
        public MsgEnum Command
        {
            get { return _command; }
            set { _command = value; }
        }

        private object _object;
        public object Object
        {
            get { return _object; }
            set { _object = value; }
        }

        public FromWinformMsg(MsgEnum command, string[] parameters)
        {
            _command = command;
            _parameters = parameters;
        }
        public FromWinformMsg(MsgEnum command, string[] parameters, object objectParam)
        {
            _command = command;
            _parameters = parameters;
            _object = objectParam;
        }
    }
    #endregion
}


